<template>
    <div class="main-template" v-bind:dataValue="showLoading">
        <div class="main-header user-box-detial">
            <div class="main-header-box">
                <yd-flexbox class="user-detial">
                    <div class="user-pic">
                        <img :src="postData.shr_info.avatar[0].image" alt="">
                    </div>
                    <yd-flexbox-item>
                        <yd-flexbox direction="vertical">
                            <yd-flexbox-item>
                                <p class="user-name">{{postData.shr_info.name}}</p>
                            </yd-flexbox-item>
                            <yd-flexbox-item>
                                <p>身份证:{{postData.shr_info.idcard}}</p>
                            </yd-flexbox-item>
                            <yd-flexbox-item>
                                <p>联系电话:{{postData.phone}}</p>
                            </yd-flexbox-item>
                            <yd-flexbox-item>
                                <p>通讯地址:{{postData.shr_info.address}}</p>
                            </yd-flexbox-item>
                        </yd-flexbox>
                    </yd-flexbox-item>
                </yd-flexbox>
            </div>
        </div>
        <div class="user-main-wrap">
            <yd-cell-group>
                <yd-cell-item arrow href="/user/edit" type="link">
                    <yd-icon slot="icon" name="ucenter" size=".42rem"></yd-icon>
                    <span slot="left">修改个人信息</span>
                </yd-cell-item>
            </yd-cell-group>
        </div>
        <div class="user-main-wrap">
            <yd-cell-group>
                <yd-cell-item arrow type="link" href="/user/reset">
                    <yd-icon slot="icon" name="order" size=".42rem"></yd-icon>
                    <span slot="left">修改登录密码</span>
                </yd-cell-item>
            </yd-cell-group>
        </div>
        <div class="user-main-wrap">
            <yd-cell-group>
                <yd-cell-item arrow @click.native="layout">
                    <yd-icon slot="icon" name="warn" size=".42rem"></yd-icon>
                    <span slot="left">退出登录</span>
                </yd-cell-item>
            </yd-cell-group>
        </div>
        <yd-tabbar slot="tabbar" class="public-footer">
            <yd-tabbar-item title="首页" link="/">
                <yd-icon name="home" slot="icon"></yd-icon>
            </yd-tabbar-item>
            <yd-tabbar-item title="投资收益" link="/income">
                <yd-icon name="shopcart-outline" slot="icon"></yd-icon>
            </yd-tabbar-item>
            <yd-tabbar-item title="信息交流" link="/message">
                <yd-icon name="like-outline" slot="icon"></yd-icon>
            </yd-tabbar-item>
            <yd-tabbar-item title="个人中心" link="/user" active>
                <yd-icon name="ucenter-outline" slot="icon"></yd-icon>
            </yd-tabbar-item>
        </yd-tabbar>
    </div>
</template>
<script>
    import Ajax from "../api/ajax.js";
    import dataURL from "../data/dataURL.js";
    import Funcs from "../service/funcs.js";
    import '../data/date.js'
    export default {
        data() {
            return {
                loadBloean: true,
                postData: {
                    "user_id": '',
                    "user_name": "",// 用户名
                    "phone": "",// 手机号
                    "role": '',// 角色
                    "status": "",// 账号状态
                    "created_at": "",//
                    "updated_at": "",//
                    "shr_info": {
                        "sh_id": '',//
                        "user_id": '',// 用户id
                        "avatar": [
                            {
                                image: "",
                            }
                        ],// 头像地址
                        "name": "",// 姓名
                        "sex": 1,// 性别
                        "idcard": "",// 身份证号
                        "birth": "",// 生日
                        "education": "",// 学历
                        "bank_name": "",// 银行名称
                        "bank_branch_name": "",// 支行名称
                        "account_name": "",// 户名
                        "account_no": "",// 账号
                        "address": "",// 地址
                        "email": "",// 邮件
                        "wechat": "",// 微信
                        "qq": "",// qq
                        "note": "",// 备注
                        "created_at": "",
                        "updated_at": ""
                    }
                }
            }
        },
        methods: {
            layout() {
                this.$dialog.confirm({
                    title: '警告',
                    mes: "确定要退出登录吗？",
                    opts: () => {
                        window.localStorage.removeItem("token");
                        window.localStorage.setItem("user_status", "outlogin");
                        // 获取管理员账号
                        window.location.reload();
                    }
                });
            },
            // 页面加载初始化
            async created() {
                try {
                    let res = await Ajax.Post(dataURL.user.info);
                    if (res.shr_info.sex == 1) {
                        res.shr_info.sex = "男"
                    } else {
                        res.shr_info.sex = "女"
                    }
                    this.postData = res;
                    console.log(this.postData);
                    this.loadBloean = false;
                } catch (error) {
                    console.log("error")
                }
            }
        },
        computed: {
            showLoading() {
                if (this.loadBloean) {
                    this.$dialog.loading.open('很快加载好了');
                } else {
                    this.$dialog.loading.close();
                }
            }
        },
        mounted() {
            this.created();
        }
    }

</script>